<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>设置我的资料</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/qcby/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/qcby/layuiadmin/style/admin.css" media="all">
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">设置我的资料</div>
          <div class="layui-card-body" pad15>
            <div class="layui-form">
              <div class="layui-form-item">
                <label class="layui-form-label">我的角色</label>
                <div class="layui-input-inline">
                  <input th:value="${role}" type="text" name="role"  readonly class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">当前角色不可更改为其它角色</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline" style="margin-left: 14px;">
                  <input th:value="${user.user}" type="text" name="username" value="xianxin" readonly class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">不可修改。一般用于后台登入名</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline" style="margin-left: 28px;">
                  <input th:value="${user.name}" type="text" name="nickname" lay-verify="nickname" autocomplete="off" placeholder="请输入昵称" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">所属班级</label>
                <div class="layui-input-inline">
                  <input th:value="${user.claName}" type="text" name="cla_name" class="layui-input">
                </div>
<!--                <div class="layui-form-mid layui-word-aux">不可修改</div>-->
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline" style="margin-left: 28px;">
                  <input th:value="${user.sex eq 0 ? '女':'男'}" type="text" name="sex"  class="layui-input">
                </div>
              </div>

              <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline" style="margin-left: 28px;">
                  <input th:value="${user.phone}" type="text" name="cellphone" lay-verify="phone" autocomplete="off" class="layui-input">
                </div>
              </div>

              <div class="layui-form-item">
                <div class="layui-input-block" style="margin-left: 80px;margin-top: 30px;">
                  <button class="layui-btn" lay-submit lay-filter="LAY-user-submit">确认修改</button>
                  <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="/qcby/layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: '/qcby/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'user' , 'set','form','jquery','cookie'],function () {
    var $ = layui.jquery;
    var admin = layui.admin;
    var form = layui.form;
    var layer = layui.layer;

    let cookie = layui.cookie;
    let session = $.cookie('the_cookie');
    if(session == null || session == ""){
      layer.alert("您还未登录，请先登录",{icon:5},function () {
        location.href="/qcby/views/user/login.html";
      });
    }

    form.render();

    //提交
    form.on('submit(LAY-user-submit)', function(obj){


      //请求登入接口
      admin.req({
        url: '/qcby/login/updataInfo' //实际使用请改成服务端真实接口
        ,data: obj.field
        ,type:'post'
        ,done: function(res){

          if(res.code == 0){

            //登入成功的提示与跳转
            layer.msg('修改成功', {
              offset: '15px'
              ,icon: 1
              ,time: 1000
            }, function(){

            });
          }else {
            layer.alert(res.msg, {icon:6});
          }
        }
      });
    });


  });
  </script>
</body>
</html>